package com.inlycat.web.intercepor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @author jarvan4dev@163.com
 * @since 2015年8月28日下午4:14:54
 * @category 
 **/
public class RequestMethodInteceptor  extends HandlerInterceptorAdapter{

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		/**
		 * 按前端要求，将请求的方法标识返还给前端
		 */
		String url = request.getRequestURI();
		//System.out.println(url);
		String[] parts = url.split("/");
		int length = parts.length;
		//System.out.println(parts[length-2]+parts[length-1]);
		response.setHeader("method",parts[length-2]+parts[length-1]);
		
		return true;
	}

}
